
<?php
     include_once('Models/ThoiKhoaBieu.php');
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        $hocki = $_POST['cbohocki'];
		$namhoc = $_POST['cbonamhoc'];
        //$nienkhoa = $_POST['cbonienkhoa'];
        //$maso = $_POST['cbomaso'];
		$mahp = $_POST['cbohp'];
        $malophp = trim($_POST['cbolophp']);
        $siso = trim($_POST['txtsiso']);
        $thu = trim($_POST['cbothu']);
        $tietbd = trim($_POST['cbotietbd']);
        $sotiet = trim($_POST['cbosotiet']);
        $maphong = trim($_POST['cbomaphong']);
        if (isset($_POST['btnxem'])){
			require('Views/Xepthoikhoabieu.php');
		}
        if (isset($_POST['btnthem'])){
            /*$lophp->setMaLopHP($malophp);
            $lophp->setHocKi($hocki);
            $lophp->setNamHoc($namhoc);
            $lophp->setMaHP($mahp);
            //$lophp->setMaLopHP($malophp);
            $lophp->setKiHieu($kihieu);
            $lophp->setSiSo($siso);
            $lophp->setTuanHoc($tuanhoc);
            $lophp->setMaSo($maso);*/
            /*if ($lophp->isExits("LopHocPhan","mahp='".$mahp."' and hocki=".$hocki." and nienkhoa='".$nienkhoa."'") <= 0)
            {
                echo "<script language=javascript> alert('Chưa có lớp học phần nào!'); </script>";
                require('Views/Capnhatlophp.php');
            }
            else{
                $result = $lophp->dsLopHPTheoHPHK();
                require('Views/Capnhatlophp.php');
            }*/
            $tkb = new ThoiKhoaBieu();
            $tkb->setMaLopHP($malophp);
            $tkb->setThu($thu);
            $tkb->setTietBD($tietbd);
            $tkb->setSoTiet($sotiet);
            $tkb->setMaPhong($maphong);
            if ($tkb->themThoiKhoaBieu() > 0){
                echo "<script language=javascript> alert('Đã thêm thành công!'); </script>";
                require('Views/Xepthoikhoabieu.php');
            }
            else{
                echo "<script language=javascript> alert('Không thêm được!'); </script>";
                require('Views/Xepthoikhoabieu.php');
            } 
            
            
        }
        if (isset($_POST['btnxoa'])){
            $tkb = new ThoiKhoaBieu();
            $tkb->setMaLopHP($malophp);
            $tkb->setThu($thu);
            $tkb->setTietBD($tietbd);
            if ($tkb->xoaThoiKhoaBieu() > 0){
                echo "<script language=javascript> alert('Đã xóa thành công!'); </script>";
                require('Views/Xepthoikhoabieu.php');
            }
            else{
                echo "<script language=javascript> alert('Không xóa được!'); </script>";
                require('Views/Xepthoikhoabieu.php');
            } 
        }
        
    }
    else{
        if ($_GET['option']=='xemthoikhoabieu'){
            require('Views/xemthoikhoabieu.php');
			//require('Views/Thoikhoabieu.php');
        }
        
        
    }
  
                                
  
?>
